class Recipe < ActiveRecord::Base
  has_many :articles, :order => "position"
  
  GROUPS = [ 
    ["Rails Recipes", 1],
    ["iPhone APP Recipes", 2]
  ]
  
  def sortable(articles)
    if articles
      articles = articles.map{|id| id.to_i}
      originally_articles = self.articles.collect(&:id)
      self.articles -= Article.find(originally_articles - articles)
      self.articles << Article.find(articles - originally_articles)
      Article.update_position(articles)
    else
      self.articles.clear
    end
  end
  
end
